home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-15 | 3.1 KB | 120 lines | [TEXT/MPS ] |
- ;********************************************************************
- ; (c) Copyright 1990-91 by Apple Computer, Inc. All rights reserved.
- ;
- ; LAPloopBack.a implements a software loopback function for IP
- ;********************************************************************
-
- TITLE 'LAPloopBack'
- CASE OBJECT
-
- ;
- ; 1.2 11/29/90 Rajesh - modified for IEEE 802.3 LAP
- ;
-
- INCLUDE 'SysErr.a'
- INCLUDE 'SysEqu.a'
- INCLUDE 'ToolEqu.a'
- INCLUDE 'Traps.a'
-
- IMPORT Lap802_read_ph
-
- LAPHeaderSize EQU 22
- SCCLockout EQU $2600
-
- ;
- ; TLoopBack(wds)
- ; struct wdsEntry *wds;
- ;
- ; Implements the loopback function for IP. When control returns to caller,
- ; the packet has been processed by the input side. Caller responsible for
- ; doing output IO completion
- ;
- TLoopBack PROC EXPORT
- ;
- ; handle loop-backs by setting up the registers to look like the
- ; Lap802_read_ph was called by the driver
-
- movem.l a2-a4,-(sp)
- ARG1 SET 3*4+4 ;&IPB->laphdr
- move.l ARG1(sp),a0 ;Get pointer to ipb's 1st WDS
- ;
- ; A0 - pointer to current WDS entry */
- ; A1 - number of bytes left in current WDS entry */
- ; A2 - pointer to next byte to copy */
- ; A3 - pointer to first byte past IEEE 802.3 header */
- ; A4 - pointer to CopyPacket */
- ;
- ; pea #'TLoopBack'
- ; _DebugStr
-
- move.l 2(a0),a3 ;Get Pointer to IEEE 802.3 header
- add.l #LAPHeaderSize,a3 ;Point past start of header, header
- ;size = 22 bytes - RAJESH NOV 20,1990
- add.l #6,a0 ;advance to next WDS
- ;
- ; compute remaining length of packet
- ;
- move.l a0,-(sp) ;save WDS pointer
- clr.l d1
- @1 add.w (a0),d1 ;add in length of this WDS entry
- add.l #6,a0 ;advance to next WDS
- move.w (a0),d0
- bne.s @1 ;if not end of WDS, loop
- move.l (sp)+,a0
-
- move.w (a0),a1 ;Get length of entry
- move.l 2(a0),a2 ;and pointer to its data
- lea.l CopyPacket, a4 ;Get addr of copy routine
- move.w sr,-(sp) ;Save current interrupt status
- move.w #SCCLockout,sr ;and disable interrupts
- jsr Lap802_read_ph ;call IEEE 802.3 packet read handler
- move.w (sp)+,sr ;replace status register
- movem.l (sp)+,a2-a4
- rts
-
-
-
- CopyPacket bra.s Cpkt
-
- CopyRest
- ;
- ; transfer the remaining bytes in the looped WDS to the input buffer
- ;
- ; A3 - input buffer pointer
- ; D3 - size of buffer
- ;
- ; A0 - pointer to current WDS entry */
- ; A1 - number of bytes left in current WDS entry */
- ; A2 - pointer to next byte to copy */
- ; A3 - pointer to first byte past IEEE 802.3 header */
- ; A4 - pointer to CopyPacket */
- ;
- Cpkt
- ; pea #'Cpkt'
- ; _DebugStr
- tst d3 ;zero requested size
- beq.s @3 ;if so, complete immediately
- move.w a1,d0
- beq.s @3
- @1 move.b (a2)+,(a3)+ ;transfer one byte
- sub.w #1,d3 ;decrement input buffer length
- sub.w #1,a1 ;decrement current wds length
- move.w a1,d0
- bne.s @2 ;if not finished with this wds, skip
- ;
- ; advance to next WDS entry
- ;
- add.l #6,a0 ;point to next WDS entry
- move.w (a0), a1 ;get its length
- move.w a1,d0
- beq.s @3 ;if zero, copy is finished
- move.l 2(a0), a2 ;and get buffer pointer
-
- @2 tst.w d3 ;decrement input buffer length
- bne.s @1 ;if room left, loop
- @3 move.w d3,d0
- rts
-
- ENDPROC
- END
-